//
//  StreamPeer.h
//  YuchBox
//
//  Created by Ivan on 11-10-7.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

/* For all stream read and write static funcions here. It is a peer to class 'IvanNetStream'
 */

#import <Foundation/Foundation.h>

@interface StreamPeer : NSObject

#pragma mark - static method
// for read
+ (NSMutableData *)readNSDataInStream:(NSInputStream *)inStream maxLength:(NSInteger)length;
+ (NSInteger)readBytesWithInStream:(NSInputStream *)inStream ptr:(UInt8 *)ptr maxLength:(NSInteger)len;
+ (UInt8)readInt8WithInstream:(NSInputStream *)inStream;
+ (UInt64)readInt64WithInStream:(NSInputStream *)inStream;
+ (NSInteger)readInt32WithInStream:(NSInputStream *)inStream;
+ (NSString *)readStringWithInStream:(NSInputStream *)inStream;
+ (void)readArrayWithInStream:(NSInputStream *)inStream outArray:(NSMutableArray *)array;

// for write
+ (void)writeBytesWithOutStream:(NSOutputStream *)outStream ptr:(UInt8 *)ptr maxLength:(NSInteger)length;
+ (void)writeInt8WithOutStream:(NSOutputStream *)outStream int8Value:(UInt8)int8Value;
+ (void)writeInt32WithOutStream:(NSOutputStream *)outStream intValue:(NSInteger)intValue;
+ (void)writeInt64WithOutStream:(NSOutputStream *)outStream int64Value:(UInt64)int64Value;
+ (void)writeStringWithOutStream:(NSOutputStream *)outStream stringValue:(NSString *)stringValue;
+ (void)writeArrayWithOutStream:(NSOutputStream *)outStream arrayValue:(NSMutableArray *)arrayValue;

// exception print
+ (void)printStreamError:(CFStreamError)error;
@end
